from Common.basepage import BasePage
from PageLocators.MainPage_locator import MainPageLocator as loc
import re
from Common.handle_log import do_log
from Common.connect_to_device import d_one

import time


class MainPage(BasePage):

    def click_share(self):
        self.click_element(loc.start_share_loc, "点击分享屏幕")

    def click_share2(self):
        self.click_element(loc.start_share2_loc, "点击分享icon")

    def click_slave_invite(self):
        self.click_element(loc.choice_dev_loc, "点击邀请从机")

    def click_ok(self):
        self.click_element(loc.ok_loc, "点击确定")

    def click_ok_after(self):
        self.click_element(loc.single_app, img_desc="点击切换模式")
        time.sleep(1)
        self.click_element(loc.fullscreen, img_desc="切换整个屏幕")
        time.sleep(1)
        self.click_element(loc.start_loc, img_desc="点击开始")
        pass

    def click_continue_ok(self):
        self.click_element(loc.ok_continue_loc, "点击系统窗口的确定")

    def click_finish_share(self):
        self.click_element(loc.finish_loc, "点击结束投屏")

    def click_back(self):
        if not self.judge_ele_exists(loc.back_loc):
            self.click_point(0.5, 0.5, img_desc="点击屏幕中心")
            time.sleep(2)
        self.click_element(loc.back_loc, "点击返回")


if __name__ == '__main__':
    MainPage(device="d_one").click_SynPlay()
    MainPage(device="d_one").click_share()
    MainPage(device="d_one").click_slave_invite()
